function walkDog(){
    return new Promise((resolve,reject) => {
        setTimeout(()=>{
            let dogWalked = false
            if(dogWalked){
                resolve("You walk 🐕")
            }else{
                reject("You didn't walk 🐕")
            }
        },1000)
    })
}


async function doChrose(){
    try{
        // 在方法中使用await需要async修饰方法
        let walkDogResult = await walkDog()
    }catch(error){  // 使用catch来捕获promise的reject
        console.error(error)
    }
}

doChrose()